package com.budwk.app.sqfwV2.enums;

import com.budwk.app.sqfw.constants.SqfwFormSummaryConstants;
import com.budwk.app.sqfw.enums.SupportBusinessTypeEnum;
import com.budwk.app.sqfwDoc.codeGeneratorV2.pdfService.CompleteFlowCommonPdfService;
import com.budwk.app.sqfwV2.component.ShawenTownComponent;
import com.budwk.app.sqfwV2.service.baiyunqu.OldPeopleSeekPdfService;
import com.budwk.app.sqfwV2.service.caringStaff.CaringStaffPdfService;
import com.budwk.app.sqfwV2.service.caringStaff.DifficultPersonPdfService;
import com.budwk.app.sqfwV2.service.childrenVisitation.ChildrenVisitationPdfService;
import com.budwk.app.sqfwV2.service.dayingRoad.RedWhiteRecordPdfService;
import com.budwk.app.sqfwV2.service.dulaying.PropagandaOrScreeningPdfService;
import com.budwk.app.sqfwV2.service.floodControlAssistant.FloodAssistantPdfService;
import com.budwk.app.sqfwV2.service.landscapePatrol.LandscapePatrolPdfService;
import com.budwk.app.sqfwV2.service.oneFive.OneFivePdfService;
import com.budwk.app.sqfwV2.service.patrolAndVisit.PatrolAndVisitPdfService;
import com.budwk.app.sqfwV2.service.propagandaScreening.PropagandaScreeningPdfService;
import com.budwk.app.sqfwV2.service.publicSecurity.PublicSecurityPdfService;
import com.budwk.app.sqfwV2.service.shawenTown.ShawenTownSafetyPdfService;
import com.budwk.app.sqfwV2.service.wasteCategoryNew.WasteCategoryNewPdfService;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum FileServiceEnum {

    WCN(SupportBusinessTypeEnum.REFUSE_CLASSIFY.getName(), new WasteCategoryNewPdfService()),
    ONE(SupportBusinessTypeEnum.ONE_TO_FIVE.getName(), new OneFivePdfService()),
    C(SupportBusinessTypeEnum.FLOOD_CONTROL_ASSISTANT.getName(), new FloodAssistantPdfService()),
    LP(SupportBusinessTypeEnum.FOREST_AND_RIVER_FLOOD_DISASTER.getName(), new LandscapePatrolPdfService()),
    CS(SupportBusinessTypeEnum.CARE_WORKER_VISIT.getName(), new CaringStaffPdfService()),
    PA(SupportBusinessTypeEnum.PROPAGANDA_OF_SAFE_CONSTRUCTION.getName(), new PatrolAndVisitPdfService()),
    PO(SupportBusinessTypeEnum.PROPAGANDA_SCREENING.getName(), new PropagandaOrScreeningPdfService()),
    PO1(SupportBusinessTypeEnum.PROPAGANDA_SCREENING_JINGYANG.getName(), new PropagandaScreeningPdfService()),
    OS(OldPeopleSeekEnum.CARE_SERVICE_RECORD_PDF.getType(), new OldPeopleSeekPdfService()),
    DP(SupportBusinessTypeEnum.DIFFICULT_PERSON_VISIT.getName(), new DifficultPersonPdfService()),
    RED(SqfwFormSummaryConstants.red_white_record, new RedWhiteRecordPdfService()),
    K(ShawenTownComponent.FILL_TYPE, new ShawenTownSafetyPdfService()),
    PS(SupportBusinessTypeEnum.PUBLIC_SECURITY.getName(), new PublicSecurityPdfService()),
    CVR(SupportBusinessTypeEnum.CHILDREN_VISITATION.getName(), new ChildrenVisitationPdfService()),


    ;

    private String fillType;
    private CompleteFlowCommonPdfService service;
    public static Class<? extends CompleteFlowCommonPdfService> getServiceByFillType(String fillType) {
        Optional<FileServiceEnum> first = Arrays.stream(values()).filter(e -> e.getFillType().equals(fillType)).findFirst();
        return first.<Class<? extends CompleteFlowCommonPdfService>>map(fileServiceEnum -> fileServiceEnum.getService().getClass()).orElse(null);
    }
}
